﻿using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class BubbleTipsItem : MonoBehaviour
{
	private BubbleTipsWin _bubbleTipsWin;
	private Text _textTips;

	void Awake()
	{
		_bubbleTipsWin = GetComponentInParent<BubbleTipsWin>();
		_textTips = transform.Find("Text").GetComponent<Text>();
		transform.SetAlpha(0f);
		//TweenAlpha.Begin(gameObject, 0.3f, 1);
		transform.DOAlpha(1f, 0.3f);
	}

	public void SetInfo(string tips)
	{
		_textTips.text = tips;
		StartCoroutine(OnTime());
	}

	private IEnumerator OnTime()
	{
		yield return new WaitForSeconds(1.5f);
		//EventDelegate.Add(TweenAlpha.Begin(gameObject, 0.3f, 0).onFinished, OnItemDestroy);
		transform.DOAlpha(0, 0.3f);
	}

	private void OnItemDestroy()
	{
		_bubbleTipsWin.RemoveItem(gameObject);
		Destroy(gameObject);
	}
}
